home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha 3.02 / source / Code ƒ / G-MainWndo.p < prev    next >
Encoding:
Text File  |  1990-09-14  |  2.9 KB  |  95 lines  |  [TEXT/PJMM]

  1. unit MainWndo;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Sound, GameUtils, Enemies, GlyphaGuts;
  7.  
  8.     procedure Init_MainWndo;
  9.     procedure Close_MainWndo;
  10.     procedure Open_MainWndo (rightOff, downOff: Integer);
  11.     procedure Update_MainWndo (whichWindow: WindowPtr);
  12.  
  13. implementation
  14.  
  15.     var
  16.         tempRect: Rect;                      {Temporary rectangle}
  17.         Index: Integer;                      {For looping}
  18.         CtrlHandle: controlhandle;           {Control handle}
  19.         sTemp: Str255;                       {Get text entered, temp holding}
  20.  
  21. {=================================}
  22.  
  23.     procedure Init_MainWndo;
  24.  
  25.     begin                                   {Start of Window initialize routine}
  26.         mainWndo := nil;                        {Make sure other routines know we are not valid yet}
  27.     end;                                    {End of procedure}
  28.  
  29. {=================================}
  30.  
  31.     procedure Close_MainWndo;
  32.  
  33.     begin
  34.         if (mainWndo <> nil) then
  35.             begin
  36.                 DisposeWindow(mainWndo);    {Clear window and controls}
  37.                 mainWndo := nil;            {Make sure other routines know we are open}
  38.             end;                    {End for if (mainWndo<>nil)}
  39.     end;
  40.  
  41. {=================================}
  42.  
  43.     procedure UpDate_MainWndo;
  44.         var
  45.             leftEdge, topEdge, rightEdge, bottomEdge: Integer;
  46.             tempRect: Rect;
  47.     begin
  48.         if (mainWndo <> nil) and (mainWndo = whichWindow) then {Handle an open when already opened}
  49.             begin
  50.                 SetPort(mainWndo);
  51.                 PenNormal;
  52.                 leftEdge := mainWndo^.portBits.bounds.left;
  53.                 topEdge := mainWndo^.portBits.bounds.top;
  54.                 rightEdge := mainWndo^.portBits.bounds.right;
  55.                 bottomEdge := mainWndo^.portBits.bounds.bottom;
  56.                 SetRect(tempRect, leftEdge, topEdge, 0, bottomEdge);
  57.                 FillRect(tempRect, black);
  58.                 SetRect(tempRect, 512, topEdge, rightEdge, bottomEdge);
  59.                 FillRect(tempRect, black);
  60.                 SetRect(tempRect, 0, topEdge, 512, 0);
  61.                 FillRect(tempRect, black);
  62.                 SetRect(tempRect, 0, 342, 512, bottomEdge);
  63.                 FillRect(tempRect, black);
  64.                 SetRect(tempRect, 0, 0, 512, 342);
  65.                 CopyBits(offVirginMap, mainWndo^.portBits, tempRect, tempRect, srcCopy, nil);
  66.                 PenMode(patXOr);
  67.                 InsetRect(tempRect, -1, -1);
  68.                 FrameRect(tempRect);
  69.                 PenNormal;
  70.             end;                            {End for if (mainWndo<>nil)}
  71.     end;
  72.  
  73. {=================================}
  74.  
  75.     procedure Open_MainWndo;
  76.         var
  77.             tempRect: Rect;
  78.     begin
  79.         if (mainWndo = nil) then        {Handle an open when already opened}
  80.             begin
  81.                 mainWndo := GetNewWindow(1, nil, Pointer(-1)); {Get window from resource}
  82.                 SelectWindow(mainWndo);    {Bring our window to the front}
  83.                 SetPort(mainWndo);        {Prepare to write into our window}
  84.                 SizeWindow(mainWndo, screenBits.bounds.right, screenBits.bounds.bottom, FALSE);
  85.                 SetOrigin(-rightOff, -downOff);
  86.                 ShowWindow(mainWndo);
  87.                 UpDate_MainWndo(mainWndo);    {Do an update to draw rest of items}
  88.             end                        {End for if (mainWndo<>nil)}
  89.         else
  90.             SelectWindow(mainWndo);        {Already open, so show it}
  91.     end;
  92.  
  93. {=================================}
  94.  
  95. end.                                    {End of unit}